/*
/   Header for all ChaosCube subprograms
*/
#include "TI_USCI_I2C_master.h"
#include "MPU6050.h"
#include <math.h>

#ifndef _ChaosCube_
  #define _ChaosCube_


void initIMU(void);
int waitRoll(void);

/* Main Initialize Function Declarations */
void initClocks(void);
void initTimeOut(void);
void initGen(void);
void initPorts(void);

void delay_ms(unsigned int num_ms);

/* IR Subsystem Function Declarations */
void initIR(void);
void sendIR(int face);

/* Visual Subsystem Function Declarations */
void initVisual(void);
void sendVisual(int face);

/* Audio Subsystem Function Declarations */
void initAudio(void);
void sendAudio(int face);


#define delay_us 8        // Number of cycles per MHz ( 1/(Freq) * 1 uS = num_cycles )


#define F_GEN 0x01
#define F_TIMEOUT  0x02

/* PORT1 Pin Definitions */
#define P_COMPARATOR_IN    BIT0
#define P_UART_RX          BIT1
#define P_UART_TX          BIT2

#define P_IR_DATA          BIT4

/* PORT2 Pin Definitions */
#define P_VISUAL_LAT       BIT0
#define P_VISUAL_SCLK      BIT1
#define P_VISUAL_SIN       BIT2
#define P_IMU_INT          BIT3

#define P_AUDIO_ENABLE     BIT5

#define PxOUT_AUDIO_ENABLE P2OUT
#define PxDIR_AUDIO_ENABLE P2DIR

/* PORT3 Pin Definitions */
#define P_VISUAL_BLANK     BIT2
#define P_VISUAL_SOUT      BIT3

#define P_AUDIO_SEL_0      BIT5
#define P_AUDIO_SEL_1      BIT6
#define P_AUDIO_SEL_2      BIT7
/* used by audio routine to bitshift the face code left */
#define AUDIO_SEL_OFFSET   5

#define PxOUT_AUDIO_SEL    P3OUT
#define PxDIR_AUDIO_SEL    P3DIR


/* Face integer value definitions */
#define failure 0
#define success 1
#define face1   2
#define face2   3
#define face3   4
#define face4   5
#define face5   6
#define face6   7

#endif
